#!/usr/bin/env python
# -*- coding:utf-8 -*-


'''
@Author : shouke
'''

import logging

logger = logging.getLogger(__name__)

class Assertioner(object):
    @classmethod
    def assert_contain(self, target, pattern_list, logic):
        '''
        断言目标对象包含预期模式
        :param target 断言对象
        :param pattern_list 断言模式
        :param logic 逻辑
        '''

        if logic.lower() == 'and':
            result = True
            for pattern in pattern_list:
                if str(target).find(str(pattern)) == -1:
                    return False
        elif logic.lower() == 'or':
            result = False
            for pattern in pattern_list:
                if str(target).find(str(pattern)) != -1:
                    return True
        return result

    @classmethod
    def assert_equal(self, target, pattern_list, logic):
        ''' 断言目标对象和预期模式相等 '''

        if logic.lower() == 'and':
            result = True
            for pattern in pattern_list:
                 if target != pattern:
                    return False
        elif logic.lower() == 'or':
            result = False
            for pattern in pattern_list:
                if target == pattern:
                    return True
        return result
